﻿using AnesSystem.Models;
using AnesSystem.Services;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AnesSystem.ViewModels
{

    public class RetypesettingCtrlViewModel : BaseViewModel<RetypesettingCtrlViewModel>
    {
        #region Variables

        private PatientLinkModel plm = DataManager.Instance.CurrentPatientLink;
        //手术间
        private ConfigOperationRoomModel _ssj = new ConfigOperationRoomModel();
        //手术计划时间
        private DateTime _jhsj = DateTime.Now;
        //台数
        private string _taishu;
        //主麻医师
        private string _zmys;
        //副麻医师
        private string _fmys;
        //麻醉方式
        private string _mzfs;
        //机械护士
        private string _jxhs;
        //巡回护士
        private string _xhhs;
        //备注
        private string _bz;
        //姓名
        private string _brxm;

        #endregion

        #region Constructor
        public RetypesettingCtrlViewModel()
        {
            //PatientLinkModel plm = new PatientLinkModel();
            if (DataManager.Instance.CurrentPatientLink != null)
            {
                _jhsj = plm.Schedule.Jhsssj;
                _ssj.Name = plm.Schedule.Pbssjh;
                _taishu = plm.Schedule.PbtsInt+"";
                _zmys = plm.Schedule.Mzysbh1;
                _fmys = plm.Schedule.Mzysbh2;
                _xhhs = plm.Schedule.Xhhsbh1;
                _jxhs = plm.Schedule.Qxhsbh1;
                _mzfs = plm.Schedule.Mzfs;
                _bz = plm.Schedule.Bznr;
                _brxm = plm.Patient.Brxm;
            }
        }


        #endregion

        #region Properties

        public PatientLinkModel Plm
        {
            get
            {
                if (plm == null)
                    plm = DataManager.Instance.CurrentPatientLink;
                return plm;
            }

            set
            {
                plm = value;
                RaisePropertyChanged("Plm");
            }
        }

        public ConfigOperationRoomModel Ssj
        {
            get
            {
                return _ssj;
            }

            set
            {
                _ssj = value;
                RaisePropertyChanged("Ssj");
            }
        }

        public DateTime Jhsj
        {
            get
            {
                return _jhsj;
            }

            set
            {
                _jhsj = value;
                RaisePropertyChanged("Jhsj");
            }
        }

        public string Taishu
        {
            get
            {
                return _taishu;
            }

            set
            {
                _taishu = value;

                RaisePropertyChanged("Taishu");
            }
        }

        public string Zmys
        {
            get
            {
                return _zmys;
            }

            set
            {
                _zmys = value;
                RaisePropertyChanged("Zmys");
            }
        }

        public string Fmys
        {
            get
            {
                return _fmys;
            }

            set
            {
                _fmys = value;
                RaisePropertyChanged("Fmys");
            }
        }

        public string Mzfs
        {
            get
            {
                return _mzfs;
            }

            set
            {
                _mzfs = value;
                RaisePropertyChanged("Mzfs");
            }
        }

        public string Jxhs
        {
            get
            {
                return _jxhs;
            }

            set
            {
                _jxhs = value;
                RaisePropertyChanged("Jxhs");
            }
        }

        public string Xhhs
        {
            get
            {
                return _xhhs;
            }

            set
            {
                _xhhs = value;
                RaisePropertyChanged("Xhhs");
            }
        }

        public string Bz
        {
            get
            {
                return _bz;
            }

            set
            {
                _bz = value;
                RaisePropertyChanged("Bz");
            }
        }

        public IEnumerable<ConfigOperationRoomModel> DisplayConfigOperationRoomModelList
        {
            get
            {
                ObservableCollection<ConfigOperationRoomModel> list = new ObservableCollection<ConfigOperationRoomModel>();
                return list.Union(DataManager.Instance.ConfigOperationRoomModelList);
            }
        }

        public string Brxm
        {
            get
            {
                return _brxm;
            }

            set
            {
                _brxm = value;
                RaisePropertyChanged("Brxm");
            }
        }

        #endregion

        #region 依赖属性

        #endregion

        #region Event

        #endregion

        #region Private Methods


        #endregion

        #region Public/Protected Methods
        public void Save()
        {
            PatientLink.Schedule.Mzysbh1 = Zmys;
            PatientLink.Schedule.Mzysbh2 = Fmys;
            PatientLink.Schedule.Pbssjh = Ssj.Name;
            PatientLink.Schedule.Xhhsbh1 = Xhhs;
            PatientLink.Schedule.Qxhsbh1 = Jxhs;
            PatientLink.Schedule.Mzfs = Mzfs;
            PatientLink.Schedule.PbtsInt = int.Parse(Taishu);
            PatientLink.Schedule.Jhsssj = Jhsj;
            PatientLink.Schedule.Bznr = Bz;
            PatientLinkService.Instance.AddUpdate(PatientLink);
            SecheduleMainCtrlViewModel.Instance.PaiTai(PatientLink, Ssj.Name);
            XuanZeShouShuCtrlViewModel.Instance.RefView();
        }



        #endregion

        #region EventHandlers

        #endregion
    }
}
